<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="项目名称" prop="ProjectName">
        <el-input
          v-model="queryParams.ProjectName"
          placeholder="请输入项目名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-button
        type="primary"
        style="float: right;"
        size="mini"
        @click="goback"
      >返回</el-button>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-table v-loading="loading" :data="projectList">
      <el-table-column label="项目名称" align="center" prop="ProjectName" />
      <el-table-column label="项目描述" align="center" prop="Description" />
      <el-table-column label="开始日期" align="center" prop="StartDate">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.StartDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="结束日期" align="center" prop="EndDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.EndDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
    </el-table>

  </div>
</template>

<script>
import { listProject } from "@/api/project/project";

export default {
  name: "Project",
  data() {
    return {
      // 显示搜索条件
      showSearch: true,
      // 查询参数
      queryParams: {
        ProjectName: null,
        Description: null,
        StartDate: null,
        EndDate: null,
      },
    };
  },
  methods: {
    goback(){
      this.$router.go(-1)
    },
    /** 查询project列表 */
    getList() {
      this.loading = true;
      listProject(this.queryParams).then(response => {
        this.projectList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 表单重置
    reset() {
      this.form = {
        ProjectId: null,
        ProjectName: null,
        Description: null,
        StartDate: null,
        EndDate: null,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
  }
};
</script>
